//
//  TreatyViewController.m
//  ZFPlatform
//
//  Created by magus on 11-5-28.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "AgreementViewController.h"
#import "RegisterViewController.h"


@implementation AgreementViewController


//通过xib资源初始化视图控制器
//
+ (AgreementViewController*) InitFromXib
{
	self = [[AgreementViewController alloc] 
			initWithNibName:@"AgreementViewController" bundle:nil];
	return self;
}


//初始化界面
//
- (void) InitAllViews
{
	//设置导航栏标题
	[self setTitle:@"注册协议"];

	//设置导航栏左按钮
	UIImage* image = [UIImage imageNamed: @"导航栏按钮（返回）.png"];
	CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
	UIButton* leftButton = [[UIButton alloc] initWithFrame:rect];
	[leftButton.titleLabel setFont:[UIFont boldSystemFontOfSize:13.0]];
	[leftButton setTitle:@" 返回" forState:UIControlStateNormal];
	[leftButton setBackgroundImage:image forState:UIControlStateNormal];
	[leftButton addTarget:self action:@selector(GoBack:) forControlEvents:UIControlEventTouchDown];
	UIBarButtonItem* leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
	self.navigationItem.leftBarButtonItem = leftItem;
	[leftItem release];
	[leftButton release];
	[image release];
}


//响应导航栏返回按钮
//
- (void) GoBack: (id) sender
{
	[self.navigationController popViewControllerAnimated:YES];
}


//同意协议 -- 切换到“注册页面”
//
- (IBAction) Agree: (id) sender
{
	if(registerViewController == nil)
		registerViewController = [RegisterViewController InitFromXib];
	
	[self.navigationController pushViewController:registerViewController animated:YES];
}


// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	//初始化界面
	[self InitAllViews];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[registerViewController release];
    [super dealloc];
}


@end
